package com.twu.biblioteca;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: Demon
 * Date: 13-6-27
 * Time: 上午10:44
 * To change this template use File | Settings | File Templates.
 */
public class MenuOption {

    //private UserLogin user;
    private static int book_list_choice=0;    //other,membership,manager can choose the book_list_choice
    private static int membership_choice=1;   //membership,manager can choose the membership_choice
    private static int management_choice=2;    //manager can choose the management_choice
    private int user_choice;
    private BookList book_list;

    public void SetUserChoice(int choice) {
        user_choice=choice;
    }

    public boolean JudgeUserChoice(int user_lever) {
        if (user_lever < user_choice) {
            System.out.println("Select a valid option!!");
            return false;
        } else {
            return true;
        }
    }

    public int ShowBookList() {
        book_list=new BookList();
        if(user_choice==0) {
            System.out.println("you have chosen the book_list option,now we will list all the books:");
            return book_list.ShowAllBookList();
        }
        else return 0;
    }

    public int CheckMemberShipDetails(){
       if(user_choice==1){
           System.out.println("you have chosen the membership option.This function hasn't been finished!");
           System.out.println("Please talk to a Librarian. Thank you.");
       }
       return 1;
    }

    public void Option(int user_level){
        System.out.println("Please input menu option:(0 is book_list option,1 is membership option,2 is management option)");
        Scanner content =new Scanner(System.in);
        int user_choice=content.nextInt();
        SetUserChoice(user_choice);
        if(JudgeUserChoice(user_level))  {
            ShowBookList();
            CheckMemberShipDetails();
        }
    }
}
